package com.hualude.roadsign.utils;


import org.apache.log4j.Logger;

/**
 * Created by wujiao on 2017/5/15.
 */
public class PushUtil {

    private static Logger LOG = Logger.getLogger(PushUtil.class);
    private final static String SourceAddr = "Hualude";
    private final static String AndroidPushTitle = "华路德";
    private final static String IOSPushTitle = "华路德";

    private final static Integer IOS_MODEL = 1;
    private final static Integer Android_MODEL = 1;

    private static void sendPush() {

    }

    public static void sendPushToUser(String userId, String msg) throws Exception {
        /*LogDao logDao = (LogDao)SpringTool.getBean("logDao");
        Dto4PushTarget dto4PushTarget = logDao.getUserPushTargetInfoByUserId(userId);
//        if(dto4PushTarget.getModel().equals(IOS_MODEL)){
//            sendIOSPush(dto4PushTarget.getToken(),msg);
//        }else{
//            sendAndroidPush(dto4PushTarget.getToken(),msg);
//        }
        if(dto4PushTarget.getModel().equals(IOS_MODEL)){
            sendIOSPushWithUserId(userId,msg);
            sendIOSMessageWithUserId(userId,msg);
        }else{*/
        sendAndroidPushWithUserId(userId, msg);

        //}
    }

    private static void sendIOSPush(String token, String msg) {
        KeKeSender.sendIOSPushNoticeInfo(SourceAddr, token, msg, "DEVICE", IOSPushTitle, "", "DEV");
    }

    private static void sendAndroidPush(String token, String msg) {
        KeKeSender.sendAndroidPushNoticeInfo(SourceAddr, token, msg, "DEVICE", AndroidPushTitle, "");
    }

    private static void sendIOSPushWithUserId(String userId, String msg) {
        KeKeSender.sendIOSPushNoticeInfo(SourceAddr, userId, msg, "ACCOUNT", IOSPushTitle, "", "DEV");
    }

    private static void sendAndroidPushWithUserId(String userId, String msg) {
        KeKeSender.sendAndroidPushNoticeInfo(SourceAddr, userId, msg, "ACCOUNT", AndroidPushTitle, "{\"Member\":\"丝滑咸鱼！\"}");
    }

    private static void sendIOSMessageWithUserId(String userId, String msg) {
        KeKeSender.sendIOSPushMessageInfo(SourceAddr, userId, msg, "ACCOUNT", IOSPushTitle);
    }

}